#ifndef COMMON_ITERABLEOPERATIONS_H
#define COMMON_ITERABLEOPERATIONS_H

#include "Common/Collections/IIterator.h"
#include "Common/Collections/IteratorPtr.h"

namespace cmn {

	template<typename T>
	bool IterablesAreEqual( const IIterable<T>* iterableA, const IIterable<T>* iterableB ) {
		IteratorPtr<T> iteratorA( iterableA );
		IteratorPtr<T> iteratorB( iterableB );

		while( !iteratorA.IsEnd() && !iteratorB.IsEnd() ) {
			T itemA = iteratorA.Current();
			T itemB = iteratorB.Current();
			if( itemA != itemB )
				return false;

			iteratorA.Next();
			iteratorB.Next();
		}
		return iteratorA.IsEnd() && iteratorB.IsEnd();
	}

	template<typename T>
	bool IterablesAreEqual( const IIterable<T>& iterableA, const IIterable<T>& iterableB ) {
		IteratorPtr<T> iteratorA( iterableA );
		IteratorPtr<T> iteratorB( iterableB );

		while( !iteratorA.IsEnd() && !iteratorB.IsEnd() ) {
			T itemA = iteratorA.Current();
			T itemB = iteratorB.Current();
			if( itemA != itemB )
				return false;

			iteratorA.Next();
			iteratorB.Next();
		}
		return iteratorA.IsEnd() && iteratorB.IsEnd();
	}
}
#endif
